<?php
	namespace Home\Model;
	use Think\Model;
	class PersonalModel extends Model{
		
		public function addSelect(){
			return $this->select();
		}
		//增加个人信息
		public function handlepersonal($data){
			if(!empty($data)){
				$personalInfo=$this->hasPersonal($data['uid']);
				$where['uid']=$data['uid'];
				if($personalInfo){
					$preReturn=$this->where($where)->save($data);
				}else{
					$perReturn=$this->add($data);
				}
				if($perReturn !== flase){
					return $this->where($where)->find();
				}else{
					return false;
				}
			}else{
				return false; 
			}
		}
		//查看一个人的个人信息
		public  function hasPersonal($uid){
			if($uid){
				$where['uid']=$uid;
				$personalList=$this->where($where)->find();
				if($personalList){
					return $personalList;
				}else{
					return false;
				}
			}
			
		}
		//改变头像
		public function addTx($data){
			if(!empty($data)){
				$where['uid']=$data['uid'];
				$userInfo['user_tx']=$data['user_tx'];
				if($this->hasPersonal($data['uid'])){
					$txList=$this->where($where)->save($userInfo);
				}else{
					$txList=$this->add($data);
				}
				if($txList){
					return $txList;
				}else{
					return false;
				}
			}
		}
	}
?>